package sv.com.renacempleo.dao.ctg;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;

import sv.com.renacempleo.dao.BaseDaoImpl;
import sv.com.renacempleo.dto.ctg.CtgCriteriosVinculacion;
import sv.com.renacempleo.exception.WebException;

public class CtgCriteriosVinculacionDaoImpl extends BaseDaoImpl implements CtgCriteriosVinculacionDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<Object[]> findAllActivesAsArray() throws WebException {
		DetachedCriteria criteria = DetachedCriteria.forClass(CtgCriteriosVinculacion.class);
		criteria.addOrder(Order.asc("ctgCriterioVinculacionPrioridad"));
		criteria.setProjection(Projections.projectionList().
				add(Projections.property("ctgCriterioVinculacionId")).
				add(Projections.property("ctgCriterioVinculacionNombre")).
				add(Projections.property("ctgCriterioVinculacionDescripcion")).
				add(Projections.property("ctgCriterioVinculacionAccionSistema")).
				add(Projections.property("ctgCriterioVinculacionTipoCriterio")).
				add(Projections.property("ctgCriterioVinculacionCalificacion")).
				add(Projections.property("ctgCriterioVinculacionFuncion")).
				add(Projections.property("ctgCriterioVinculacionUso")).
				add(Projections.property("ctgCriterioVinculacionChequeado")).
				add(Projections.property("ctgCriterioVinculacionPrioridad"))
			);
		return (List<Object[]>) findByCriteria(criteria);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Object[]> findAllChecked() throws WebException {
		DetachedCriteria criteria = DetachedCriteria.forClass(CtgCriteriosVinculacion.class);
		criteria.addOrder(Order.asc("ctgCriterioVinculacionPrioridad"));
		criteria.setProjection(Projections.projectionList().
				add(Projections.property("ctgCriterioVinculacionId")).
				add(Projections.property("ctgCriterioVinculacionNombre")).
				add(Projections.property("ctgCriterioVinculacionAccionSistema")).
				add(Projections.property("ctgCriterioVinculacionCalificacion")).
				add(Projections.property("ctgCriterioVinculacionChequeado"))
			);
		return (List<Object[]>) findByCriteria(criteria);
	}

}
